<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

inicializa();

function inicializa(){ 
    
    if (file_exists(dirname(__FILE__).'/config.php')):
        require_once(dirname(__FILE__).'/config.php');
    else:
        die(utf8_decode('Configuration file not found, contacte administrator !!!'));
    endif;
    
    if(!defined("BASEPATH") || !defined("BASEURL")   || !defined("ADMURL") 
                            || !defined("CLASSPATH") || !defined("MODULOPATH") 
                            || !defined("CSSPATH")   || !defined("JSPATH")):
        die(utf8_decode('Missing basic system configuration, contacte administrator !!!'));
    endif;
    
    if(!defined("DBHOST") || !defined("DBUSER") || !defined("DBPASS") || !defined("DBNAME")):
        die(utf8_decode('Missin database basic configuration, contacte administrator !!!'));
    endif;
    
    require_once(BASEPATH.CLASSPATH.'autoload.php');
} // inicializa

 function loadCSS($arquivo=null,$media='screen',$import=false){
     if ($arquivo != NULL):
         IF ($import==TRUE):
             echo '<style type="text/css">@import url("'.BASEURL.CSSPATH.$arquivo.'.css");</style>'."\n";
         else:
             echo '<link rel="stylesheet" type="text/css" href="'.BASEURL.CSSPATH.$arquivo.'.css" media="'.$media.'" />'."\n";
         endif;
     endif;
 } // loadCSS
 
 function loadJS($arquivo=null, $remoto=false){
     if ($arquivo!= NULL):
         if($remoto==FALSE)$arquivo = BASEURL.JSPATH.$arquivo.'.js';
         echo '<script type= "text/javascript" src="'.$arquivo.'"></script>'."\n";
     endif;
 } // loadJS
 
 function loadModulo ($modulo=null,$tela=null){
     if($modulo==NULL || $tela==NULL):
         echo '<p>FunctionError <strong>'.__FUNCTION__.'</stron>: Missing parameters.';
     else:
         if (file_exists(MODULOPATH."$modulo.php")):
             include_once(MODULOPATH."$modulo.php");
         else:
             echo '<p>Module nos exist in the system.</p>';
         endif;
     endif;
 } // loadModulo
 
 function restrictFile($fileName, $redirfor='index.php?erro=3'){
     $url = $_SERVER["PHP_SELF"];
     if (preg_match("/$fileName/i", $url)):
         redirect($redirfor);
     endif;
 } // restrictFile
 
 function redirect($url=""){
    header("location: ".BASEURL.$url);
 } //redirect
 
?>
